package com.five.admin.utils;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Random;

public class OrderNoGenerator {
    public static String generate(Long userId) {
        // 规则：yyyyMMddHHmmss + 3位随机数 + 用户ID后4位
        String date = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
        String random = String.format("%03d", new Random().nextInt(1000));
        String userIdSuffix = String.format("%04d", userId % 10000);
        return date + random + userIdSuffix;
    }
}